package testing.unit;

import static org.junit.Assert.assertTrue;
import game.components.Cordinent;
import game.components.Player;
import game.components.StartingPosition;
import game.components.squares.GamePiece;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class GamePieceTest
{

	Player		player1;
	Player		player2;
	GamePiece	bomb;
	GamePiece	flag;
	GamePiece	three;
	GamePiece	spy;
	GamePiece	seven;
	GamePiece	ten;

	@Before
	public void setUp() throws Exception
	{

		player1 = new Player("Player 1", StartingPosition.Top);
		player2 = new Player("Player 2", StartingPosition.Bottom);
		Cordinent l = new Cordinent(0, 0);

		bomb = new GamePiece(l, player1, 11);
		flag = new GamePiece(l, player2, 0);
		three = new GamePiece(l, player1, 3);
		spy = new GamePiece(l, player2, 1);
		seven = new GamePiece(l, player1, 7);
		ten = new GamePiece(l, player2, 10);
	}

	@After
	public void tearDown() throws Exception
	{
		player1 = null;
		player2 = null;
		bomb = null;
		flag = null;
		three = null;
		spy = null;
		seven = null;
		ten = null;
	}

	@Test
	public void testCompareTo()
	{

		assertTrue(bomb.compareTo(three) == -1);
		assertTrue(three.compareTo(bomb) == 1);
		assertTrue(seven.compareTo(bomb) == -1);
		assertTrue(bomb.compareTo(seven) == 1);

		assertTrue(spy.compareTo(ten) == 1);
		assertTrue(ten.compareTo(spy) == -1);
		assertTrue(ten.compareTo(seven) == 1);
		assertTrue(seven.compareTo(ten) == -1);

		assertTrue(seven.compareTo(three) == 1);
		assertTrue(three.compareTo(seven) == -1);

		assertTrue(seven.compareTo(seven) == 0);
		assertTrue(three.compareTo(three) == 0);
	}
}
